home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Configuration_En / Commands / Object Options.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  3.0 KB  |  96 lines

  1. //
  2. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  3. // ----------------------------------------------------
  4. //
  5. // Object Options.js
  6. //
  7. // This command adds attributes to the following objects: generator, shockwave, flash.
  8. // when the preferences for accessibility are checked.
  9. //
  10. // Version 1.0
  11. // Functions:
  12. //
  13. // setAccessibilityAttrib: sets the attributes to the object selected by generator.js, activex.htm, flash.js, shockwave.js
  14. // receives: string with object tag; if cancel the same string is returned.
  15. // returns: if any accessibility attribute is supplied it returns the object tag with added attributes.
  16. // ----------------------------------------------------
  17.  
  18. var globalFormItem;
  19. var returnTag='';
  20. var helpDoc = MM.HELP_objObjectAccessOptions;
  21.  
  22. function commandButtons() {
  23.    return new Array(MM.BTN_OK,         "setAccessibilityStr(); window.close()",
  24.                     MM.BTN_Cancel,     "window.close()",
  25.                     MM.BTN_Help,       "displayHelp()"    );
  26.  
  27.  
  28. }
  29.  
  30. function isDOMRequired() { 
  31.     // Return false, indicating that this object is available in code view.
  32.     return false;
  33. }
  34.  
  35. function setFormItem(formItem) {
  36.  
  37.     globalFormItem = formItem;     
  38.     returnTag= formItem;
  39. }
  40.  
  41. function setAccessibilityStr()
  42. {
  43.  
  44.     var rtnStr= globalFormItem;
  45.  
  46.     var title='', tabindex='', accesskey='',objStr='' ;
  47.     var objFile = dreamweaver.getConfigurationPath() + "/Commands/Object Options.htm";
  48.     var objDOM = dreamweaver.getDocumentDOM(objFile);
  49.     
  50.     title= objDOM.theForm.title.value;
  51.     tabindex= objDOM.theForm.tabindex.value;
  52.     accesskey= objDOM.theForm.accesskey.value;
  53.  
  54.     var tempFile = dreamweaver.getConfigurationPath() + "/Shared/Common/Cache/empty.htm";
  55.     docDOM = dw.getDocumentDOM(tempFile);
  56.  
  57.     docDOM.body.innerHTML=globalFormItem;
  58.  
  59.     // media objects include plugin, applet and object tags; first define which tag to manage.
  60.     var patternObject= /object/i;
  61.     var patternApplet= /applet/i;
  62.     var patternEmbed= /embed/i;
  63.  
  64.     if (patternObject.test(globalFormItem)) {objStr= docDOM.getElementsByTagName('object');} 
  65.         else {if (patternEmbed.test(globalFormItem)){objStr= docDOM.getElementsByTagName('embed');}
  66.             else {if (patternApplet.test(globalFormItem)){objStr= docDOM.getElementsByTagName('applet');} }}
  67.  
  68.     if (title != '') objStr[0].setAttribute('title', title);
  69.     if (accesskey != '') objStr[0].setAttribute('accesskey', accesskey);
  70.     if (tabindex != '') objStr[0].setAttribute('tabindex', tabindex);
  71.     
  72.     returnTag= docDOM.body.innerHTML;
  73. }
  74.  
  75.  
  76. function returnAccessibilityStr(){
  77.  
  78.     return returnTag;
  79. }
  80.  
  81. // to do: implement data entry validation
  82. function validateEntry() {
  83.  
  84.     var validateAccess= 0; 
  85.     var validateTabIndex =0;
  86.  
  87.     while (validateAccess != 1 && validateTabIndex != 1){
  88.  
  89.         tabindex= objDOM.theForm.tabindex.value;
  90.         accesskey= objDOM.theForm.accesskey.value;
  91.  
  92.         if (accesskey.length ) {alert(MSG_ACCESSKEY);} else {validateAccess= 1;}
  93.         if (tabindex == NaN || tabindex > 32767 || tabindex < -32767) {alert(MSG_TABINDEX);} else {validateTabIndex= 1;}
  94.     }
  95. }
  96.